<?php
(!defined('IN_SYSTEM') || !defined('ADMIN_PRE')) && exit('Access Denied!');
$f = isset($_REQUEST['f'])?$_REQUEST['f']:'index';
if(isset($_G['usergroup']['access']["pdt$f"]) && !ican("pdt$f")){
	msg('没有权限');
}
$m = new ProductModule;
$m->$f();
class ProductModule
{
	function index(){
		global $_G;
		
		$seller=getGP('seller','G');
		$pname=getGP('pname','G');
		$pstatus=getGP('pstatus','G');
		if( $seller ){
			$where=" AND s.shopname like '%$seller%'";
			$url="&seller=$seller";
		}
		if( $pname ){
			$where.=" AND p.title like '%$pname%'";
			$url.="&pname=$pname";
		}
		if($pstatus=='0'){
			$where.=" AND p.status=0";
			$url.="&pstatus=0";
		}
		if($pstatus=='1'){
			$where.=" AND p.status=1";
			$url.="&pstatus=1";
		}
		$status=array('售完','出售中');
		$sql='';
		$num=$_G['db']->result("SELECT COUNT(*) FROM".table('product')."p LEFT JOIN".table("shops")."s ON p.shopid=s.shopid WHERE 1".$where);
		$query=$_G['db']->page_query("SELECT p.*,s.shopname FROM".table('product')."p LEFT JOIN".table("shops")."s ON p.shopid=s.shopid WHERE 1".$where);
		while($data=$_G['db']->fetch_array($query)){
			$result[]=$data;
		}
		$page=pager($num,10,null,"admin.php?m=product&".$url);
		include admintemplate('product/index');
	}
	
	function add(){
		global $_G;
		
		include admintemplate('product/add');
	}
	function delete(){
		$id=getGP('id','G','int');
		if(!$id){
			msg('参数错误');
		}
		//
	}
}	
?>